package io.github.yotta.common.server.example.filter;

import io.github.yotta.common.api.exception.ServiceException;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;



/**
 * @author yotta
 * @date 2023/8/4 14:31
 * 模拟filter异常出现，是否会被捕获 FilterChainExceptionHandlerFilter 处理
 */
@Component
public class TestFilterChainExceptionHandlerFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("TestFilterChainExceptionHandlerFilter .....");
        final long l = System.currentTimeMillis();
        if (true) {
            throw new ServiceException("filter error");
        }
    }
}
